package com.enqualcomm.kids.mvp.pay;

import android.util.Xml;

import org.xmlpull.v1.XmlPullParser;

import java.io.StringReader;

/**
 * Created by Yinzhiqun on 2016/8/6.
 */
public class WXPrePay {
    public String return_code;
    //    public String appid;
//    public String mch_id;
//    public String nonce_str;
//    public String sign;
    public String result_code;
    public String trade_type;
    public String prepay_id;
    public String orderid;

    public WXPrePay(String s, String orderid) {
        this.orderid = orderid;
        // xml解析
        XmlPullParser xmlPullParser = Xml.newPullParser();
        try {
            xmlPullParser.setInput(new StringReader(s));
            int eventType = xmlPullParser.getEventType();
            while (eventType != XmlPullParser.END_DOCUMENT) {
                if (eventType == XmlPullParser.START_TAG) {
                    switch (xmlPullParser.getName()) {
                        case "return_code":
                            return_code = xmlPullParser.nextText();
                            break;
                        case "result_code":
                            result_code = xmlPullParser.nextText();
                            break;
                        case "trade_type":
                            trade_type = xmlPullParser.nextText();
                            break;
                        case "prepay_id":
                            prepay_id = xmlPullParser.nextText();
                            break;

                    }
                }
                eventType = xmlPullParser.next();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }


    }
}
